package 双指针;

import java.util.Arrays;

/**
 * @author tmh
 * @date 2025/3/6 17:18
 * @description
 */
public class T283移动零 {
    public static void main(String[] args) {
        int[] nums = {2,1};
        moveZeroes(nums);
        System.out.println(Arrays.toString(nums));
    }
    public static void moveZeroes(int[] nums) {
        int left=0;
        for (int i=0;i<nums.length;i++){
            if (nums[i]!=0){
                nums[left]=nums[i];
                if (left!=i){
                    nums[i]=0;
                }
                left++;
            }

        }
    }
}
